home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWBmpShp.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  18.8 KB  |  671 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWBmpShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        4/11/94
  7. //
  8. //    Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWBMPSHP_H
  13. #include "FWBmpShp.h"
  14. #endif
  15.  
  16. #ifndef FWSHAPE_H
  17. #include "FWShape.h"
  18. #endif
  19.  
  20. #ifndef FWDFAULT_H
  21. #include "FWDfault.h"
  22. #endif
  23.  
  24. #ifndef FWGC_H
  25. #include "FWGC.h"
  26. #endif
  27.  
  28. #ifndef FWPICSHP_H
  29. #include "FWPicShp.h"
  30. #endif
  31.  
  32. // ----- OpenDoc Includes -----
  33.  
  34. #ifndef _TRNSFORM_
  35. #include <Trnsform.h>
  36. #endif
  37.  
  38. // ----- Macintosh Includes -----
  39.  
  40. #if defined(FW_BUILD_MAC) && !defined(mathRoutinesIncludes)
  41. #include <math routines.h>
  42. #endif
  43.  
  44. #if defined(FW_BUILD_MAC) && !defined(__QUICKDRAW__)
  45. #include <QuickDraw.h>
  46. #endif
  47.  
  48. //========================================================================================
  49. //    •• RunTime Info
  50. //========================================================================================
  51.  
  52. #ifdef FW_BUILD_MAC
  53. #pragma segment fwgraphx
  54. #endif
  55.  
  56. //========================================================================================
  57. //    •• CLASS FW_CBitmapShape
  58. //========================================================================================
  59.  
  60. //----------------------------------------------------------------------------------------
  61. // FW_CBitmapShape::FW_CBitmapShape
  62. //----------------------------------------------------------------------------------------
  63.  
  64. FW_CBitmapShape::FW_CBitmapShape() :
  65.     FW_CShape()
  66. {
  67. }
  68.  
  69. //----------------------------------------------------------------------------------------
  70. // FW_CBitmapShape::FW_CBitmapShape
  71. //----------------------------------------------------------------------------------------
  72.  
  73. FW_CBitmapShape::FW_CBitmapShape(char* image, short width, short height, short rowbytes, short pixelSize, const FW_CRect& rect) :
  74.     FW_CShape()
  75. {
  76.     FW_CRect dstRect(rect);
  77.     if (dstRect == FW_kZeroRect)
  78.         dstRect.Set(0, 0, ff(width), ff(height));
  79.     SetRep(new FW_CBitmapShapeRep(image, width, height, rowbytes, pixelSize, dstRect));
  80. }
  81.  
  82. //----------------------------------------------------------------------------------------
  83. // FW_CBitmapShape::FW_CBitmapShape
  84. //----------------------------------------------------------------------------------------
  85.  
  86. FW_CBitmapShape::FW_CBitmapShape(short width, short height, short pixelSize, const FW_CRect& rect) :
  87.     FW_CShape()
  88. {
  89.     FW_CRect dstRect(rect);
  90.     if (dstRect == FW_kZeroRect)
  91.         dstRect.Set(0, 0, ff(width), ff(height));
  92.     SetRep(new FW_CBitmapShapeRep(NULL, width, height, 0, pixelSize, dstRect));
  93. }
  94.  
  95. //----------------------------------------------------------------------------------------
  96. // FW_CBitmapShape::FW_CBitmapShape
  97. //----------------------------------------------------------------------------------------
  98.  
  99. FW_CBitmapShape::FW_CBitmapShape(FW_PlatformPict platformPict, const FW_CRect& rect) :
  100.     FW_CShape()
  101. {
  102.     FW_CRect dstRect(rect);
  103.     if (dstRect == FW_kZeroRect)
  104.     {
  105. #ifdef FW_BUILD_MAC
  106.         dstRect = (*platformPict)->picFrame;
  107.         dstRect.Place(0,0);
  108. #endif
  109.     }
  110.     SetRep(new FW_CBitmapShapeRep(platformPict, rect));
  111. }
  112.  
  113. //----------------------------------------------------------------------------------------
  114. // FW_CBitmapShape::FW_CBitmapShape
  115. //----------------------------------------------------------------------------------------
  116.  
  117. FW_CBitmapShape::FW_CBitmapShape(const FW_CBitmapShape& other) :
  118.     FW_CShape() // The compiler refuse to take FW_CShape(other)
  119. {
  120.     SetRep(other.GetRep());    
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. // FW_CBitmapShape::FW_CBitmapShape
  125. //----------------------------------------------------------------------------------------
  126.  
  127. FW_CBitmapShape::FW_CBitmapShape(FW_CBitmapShapeRep* rep) :
  128.     FW_CShape(rep)
  129. {
  130. }
  131.  
  132. //----------------------------------------------------------------------------------------
  133. // FW_CBitmapShape::operator=
  134. //----------------------------------------------------------------------------------------
  135.  
  136. FW_CBitmapShape& FW_CBitmapShape::operator=(const FW_CBitmapShape& other)
  137. {
  138.     SetRep(other.GetRep());
  139.     return *this;
  140. }
  141.  
  142. //----------------------------------------------------------------------------------------
  143. // FW_CBitmapShape::operator=
  144. //----------------------------------------------------------------------------------------
  145.  
  146. FW_CBitmapShape& FW_CBitmapShape::operator=(FW_CBitmapShapeRep* other)
  147. {
  148.     SetRep(other);
  149.     return *this;
  150. }
  151.  
  152. //----------------------------------------------------------------------------------------
  153. // FW_CBitmapShape::operator FW_CPictShape
  154. //----------------------------------------------------------------------------------------
  155.  
  156. FW_CBitmapShape::operator FW_CPictShape() const
  157. {
  158.     FW_CPictShape pictShape((FW_PlatformPict)NULL, FW_kZeroRect);
  159.     ((FW_CBitmapShapeRep*)GetRep())->ConvertToPict(pictShape);
  160.     return pictShape;
  161. }
  162.  
  163. //========================================================================================
  164. //    •• CLASS FW_CBitmapShapeRep
  165. //========================================================================================
  166.  
  167. //----------------------------------------------------------------------------------------
  168. // FW_CBitmapShapeRep::FW_CBitmapShapeRep
  169. //----------------------------------------------------------------------------------------
  170.  
  171. FW_CBitmapShapeRep::FW_CBitmapShapeRep() :
  172.     FW_CBoundedShapeRep(gGraphicGlobales.gBitmap, FW_kZeroRect),
  173. #ifdef FW_BUILD_MAC
  174.     fMacGWorld(NULL),
  175.     fInitialPixelSize(0)
  176. #endif
  177. {
  178. }
  179.  
  180. //----------------------------------------------------------------------------------------
  181. // FW_CBitmapShapeRep::FW_CBitmapShapeRep
  182. //----------------------------------------------------------------------------------------
  183.  
  184. FW_CBitmapShapeRep::FW_CBitmapShapeRep(char* image, 
  185.                                         short width, short height, 
  186.                                         short rowbytes, short pixelSize, 
  187.                                          const FW_CRect& rect) :
  188.     FW_CBoundedShapeRep(gGraphicGlobales.gBitmap, rect),
  189. #ifdef FW_BUILD_MAC
  190.     fMacGWorld(NULL),
  191.     fInitialPixelSize(pixelSize)
  192. #endif
  193. {
  194.  
  195. #ifdef FW_BUILD_MAC
  196.     NewGWorld(width, height, pixelSize);
  197.     MacSetImage(image, rowbytes);
  198. #endif
  199.  
  200. }
  201.  
  202. //----------------------------------------------------------------------------------------
  203. // FW_CBitmapShapeRep::FW_CBitmapShapeRep
  204. //----------------------------------------------------------------------------------------
  205.  
  206. FW_CBitmapShapeRep::FW_CBitmapShapeRep(FW_PlatformPict platformPict, const FW_CRect& rect) :
  207.     FW_CBoundedShapeRep(gGraphicGlobales.gBitmap, rect)
  208. {
  209. #ifdef FW_BUILD_MAC
  210.     Rect pictRect = rect;
  211.     ::OffsetRect(&pictRect, -pictRect.left, -pictRect.top);
  212.     
  213.     fInitialPixelSize = 0;
  214.     NewGWorld(pictRect.right, pictRect.bottom, 0);
  215.     MacSetImage(platformPict, pictRect);
  216. #endif
  217.  
  218. #ifdef FW_BUILD_WIN
  219. #endif
  220. }
  221.  
  222. //----------------------------------------------------------------------------------------
  223. // FW_CBitmapShapeRep::~FW_CBitmapShapeRep
  224. //----------------------------------------------------------------------------------------
  225.  
  226. FW_CBitmapShapeRep::~FW_CBitmapShapeRep()
  227. {
  228. #ifdef FW_BUILD_MAC
  229.     if (fMacGWorld)
  230.         DisposeGWorld(fMacGWorld);
  231.     fMacGWorld = NULL;
  232. #endif
  233.  
  234. #ifdef FW_BUILD_WIN
  235. #endif
  236. }
  237.  
  238. #ifdef FW_BUILD_MAC
  239. //----------------------------------------------------------------------------------------
  240. // FW_CBitmapShapeRep::NewGWorld
  241. //----------------------------------------------------------------------------------------
  242.  
  243. void FW_CBitmapShapeRep::NewGWorld(short width, short height, short pixelSize)
  244. {
  245.     GWorldPtr world = NULL;
  246.     
  247.     fHeight = height;
  248.     fWidth = width;    
  249.     if (fHeight != 0 && fWidth != 0)
  250.     {
  251.         Rect boundsRect = {0, 0, fHeight, fWidth};
  252.         
  253.         if (::NewGWorld(&world, pixelSize, &boundsRect, NULL, NULL, 0) != noErr)
  254.         {
  255.             // change to exception
  256.             FW_DEBUG_MESSAGE("NewGWorld error");
  257.         }
  258.     }
  259.     
  260.     fMacGWorld = world;
  261. }
  262. #endif
  263.  
  264. #ifdef FW_BUILD_MAC
  265. //----------------------------------------------------------------------------------------
  266. // FW_CBitmapShapeRep::MacSetImage
  267. //----------------------------------------------------------------------------------------
  268.  
  269. void FW_CBitmapShapeRep::MacSetImage(char* image, short rowBytes)
  270. {    
  271.     if (image != NULL)
  272.     {
  273.         PixMapHandle pixMap = LockPixels();
  274.         
  275.         Ptr baseAddr = ::GetPixBaseAddr(pixMap);
  276.         
  277.         if ((*pixMap)->rowBytes == rowBytes)
  278.         {
  279.             // ----- Copy in one block -----
  280.             FW_PrimitiveCopyMemory(image, baseAddr, fHeight * rowBytes);
  281.         }
  282.         else
  283.         {
  284.             // ----- Copy line by line -----
  285.             Ptr source = image;
  286.             short srcRowBytes = rowBytes;
  287.             Ptr destination = baseAddr;
  288.             short dstRowBytes = (*pixMap)->rowBytes;
  289.             short nbBytes = srcRowBytes < dstRowBytes ? srcRowBytes : dstRowBytes;
  290.             for (short i = 0; i<fHeight; i++)
  291.             {
  292.                 FW_PrimitiveCopyMemory(source, destination, nbBytes);
  293.                 source += srcRowBytes;
  294.                 destination += dstRowBytes;
  295.             }
  296.         }
  297.         
  298.         ::UnlockPixels(pixMap);
  299.     }
  300. }
  301. #endif
  302.  
  303. #ifdef FW_BUILD_MAC
  304. //----------------------------------------------------------------------------------------
  305. // FW_CBitmapShapeRep::LockPixels
  306. //----------------------------------------------------------------------------------------
  307.  
  308. PixMapHandle FW_CBitmapShapeRep::LockPixels()
  309. {
  310.     PixMapHandle pixMap = ::GetGWorldPixMap(fMacGWorld);
  311.     ::LockPixels(pixMap);
  312.     return pixMap;
  313. }
  314. #endif
  315.  
  316. #ifdef FW_BUILD_MAC
  317. //----------------------------------------------------------------------------------------
  318. // FW_CBitmapShapeRep::MacSetImage
  319. //----------------------------------------------------------------------------------------
  320.  
  321. void FW_CBitmapShapeRep::MacSetImage(PicHandle picture, const FW_SPlatformRect& dstRect)
  322. {
  323.     CGrafPtr     curPort;
  324.     GDHandle     gdh;
  325.     ::GetGWorld(&curPort, &gdh);
  326.     ::SetGWorld(fMacGWorld, NULL);
  327.     
  328.     PixMapHandle pmh = LockPixels();
  329.     ::DrawPicture(picture, &dstRect);
  330.     ::UnlockPixels(pmh);
  331.     
  332.     ::SetGWorld(curPort, gdh);
  333. }
  334. #endif
  335.  
  336. //----------------------------------------------------------------------------------------
  337. // FW_CBitmapShapeRep::HitTest
  338. //----------------------------------------------------------------------------------------
  339.  
  340. FW_HitTestPart FW_CBitmapShapeRep::HitTest(const FW_CPoint& test) const
  341. {
  342.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  343.     return FW_kOutside;
  344. }
  345.  
  346. //----------------------------------------------------------------------------------------
  347. // FW_CBitmapShapeRep::Draw
  348. //----------------------------------------------------------------------------------------
  349.  
  350. void FW_CBitmapShapeRep::Draw(FW_CGraphicContext* gc)
  351. {
  352.     FW_ShapeFills shapeFill = GetShapeFill();
  353.  
  354.     if (shapeFill == FW_kNullShape)
  355.         return;
  356.         
  357.     gc->SelectInkAndStyle(GetShapeInk(), GetShapeStyle(), FW_kBitmapShape, shapeFill);
  358.  
  359.     FW_SPlatformRect dstRect = gc->AsPlatformRect(fRect);
  360.  
  361. #ifdef FW_BUILD_MAC
  362.     Rect srcRect = {0, 0, fHeight, fWidth};
  363.     PixMapHandle pmh = LockPixels();
  364.     ::CopyBits((BitMap*)*pmh, &XMPASLMQDGlobals.thePort->portBits, 
  365.                 &srcRect, &dstRect, 
  366.                 GetShapeInk()->GetTransferMode(), NULL);
  367.     ::UnlockPixels(pmh);
  368. #endif
  369.  
  370. #ifdef FW_BUILD_WIN
  371. #endif
  372. }
  373.  
  374. //------------------------------------------------------------------------------
  375. //    • FW_CBitmapShapeRep::SetAsDefault
  376. //------------------------------------------------------------------------------
  377.  
  378. void FW_CBitmapShapeRep::SetAsDefault() const
  379. {
  380.     SetDefaultProperties(gGraphicGlobales.gBitmap);
  381. }
  382.  
  383. //------------------------------------------------------------------------------
  384. //    • FW_CBitmapShapeRep::GetPixel
  385. //------------------------------------------------------------------------------
  386.  
  387. long FW_CBitmapShapeRep::GetPixel(short x, short y) const
  388. {
  389.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  390.     return 0;
  391. }
  392.  
  393. //------------------------------------------------------------------------------
  394. //    • FW_CBitmapShapeRep::GetPixel
  395. //------------------------------------------------------------------------------
  396.  
  397. long FW_CBitmapShapeRep::GetPixel(short x, short y, FW_CColor& color) const
  398. {
  399.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  400.     return 0;
  401. }
  402.  
  403. //------------------------------------------------------------------------------
  404. //    • FW_CBitmapShapeRep::SetPixel
  405. //------------------------------------------------------------------------------
  406.  
  407. void FW_CBitmapShapeRep::SetPixel(short x, short y, long index)
  408. {
  409.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  410. }
  411.  
  412. //------------------------------------------------------------------------------
  413. //    • FW_CBitmapShapeRep::SetPixel
  414. //------------------------------------------------------------------------------
  415.  
  416. void FW_CBitmapShapeRep::SetPixel(short x, short y, const FW_CColor& color)
  417. {
  418.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  419. }
  420.  
  421. //------------------------------------------------------------------------------
  422. //    • FW_CBitmapShapeRep::GetBitmapInfo
  423. //------------------------------------------------------------------------------
  424.  
  425. void FW_CBitmapShapeRep::GetBitmapInfo(short& width, 
  426.                                         short& height, 
  427.                                         short& rowBytes,
  428.                                         short& pixelSize) const
  429. {
  430.     width = fWidth; 
  431.     height = fHeight;
  432.  
  433. #ifdef FW_BUILD_MAC
  434.     PixMapHandle pixMap = ::GetGWorldPixMap(fMacGWorld);
  435.     rowBytes = (*pixMap)->rowBytes ^ 0x8000;
  436.     pixelSize = (*pixMap)->pixelSize;
  437. #endif
  438.  
  439. #ifdef FW_BUILD_WIN
  440.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  441. #endif
  442. }
  443.  
  444. //------------------------------------------------------------------------------
  445. //    • FW_CBitmapShapeRep::ChangeBitmap
  446. //------------------------------------------------------------------------------
  447.  
  448. void FW_CBitmapShapeRep::ChangeBitmap(char* image, short width, short height, short rowBytes, short pixelSize)
  449. {
  450. #ifdef FW_BUILD_MAC
  451.     if (fMacGWorld == NULL)
  452.     {
  453.         NewGWorld(width, height, pixelSize);
  454.     }
  455.     else
  456.     {
  457.         Rect boundsRect = {0, 0, height, width};
  458.         ::UpdateGWorld(&fMacGWorld, pixelSize, &boundsRect, NULL, NULL, 0);
  459.     }
  460.     MacSetImage(image, rowBytes);
  461.     fInitialPixelSize = pixelSize;
  462. #endif
  463.  
  464.     Changed();
  465. }
  466.  
  467. //------------------------------------------------------------------------------
  468. //    • FW_CBitmapShapeRep::SetBitmapParts
  469. //------------------------------------------------------------------------------
  470.  
  471. void FW_CBitmapShapeRep::SetBitmapParts(FW_PlatformPict platformPict, const FW_SPlatformRect& bounds)
  472. {
  473. #ifdef FW_BUILD_MAC
  474.     if (fMacGWorld == NULL)
  475.         NewGWorld(bounds.right - bounds.left, bounds.bottom - bounds.top, 0);
  476.     
  477.     MacSetImage(platformPict, bounds);
  478.     fInitialPixelSize = 0;
  479. #endif
  480.  
  481. #ifdef FW_BUILD_WIN
  482. #endif
  483. }
  484.  
  485. //------------------------------------------------------------------------------
  486. //    • FW_CBitmapShapeRep::GetBitmapParts
  487. //------------------------------------------------------------------------------
  488.  
  489. FW_CBitmapShape FW_CBitmapShapeRep::GetBitmapParts(const FW_CRect& bounds)
  490. {
  491.     // ATTENTION: temporary code
  492. #ifdef FW_BUILD_MAC
  493.     Rect srcRect = bounds;
  494.     if (srcRect.right > fWidth)
  495.         srcRect.right = fWidth;
  496.     if (srcRect.bottom > fHeight)
  497.         srcRect.bottom = fHeight;
  498.     
  499.     Rect dstRect = srcRect;
  500.     ::OffsetRect(&dstRect, -dstRect.left, -dstRect.top);
  501.     
  502.     short width, height, pixelSize, rowBytes;
  503.     GetBitmapInfo(width, height, rowBytes, pixelSize);
  504.     
  505.     FW_CBitmapShape dstBmpShape(dstRect.right, dstRect.bottom, pixelSize);
  506.     
  507.     CopyPixels(dstBmpShape, srcRect, dstRect);
  508.             
  509.     return dstBmpShape;
  510. #endif
  511.  
  512. #ifdef FW_BUILD_WIN
  513. #endif
  514. }
  515.  
  516. //------------------------------------------------------------------------------
  517. //    • FW_CBitmapShapeRep::CopyPixels
  518. //------------------------------------------------------------------------------
  519.  
  520. void FW_CBitmapShapeRep::CopyPixels(const FW_CBitmapShape& dstShape, 
  521.                                     const FW_SPlatformRect& srcRect, 
  522.                                     const FW_SPlatformRect& dstRect)
  523. {
  524. #ifdef FW_BUILD_MAC
  525.     PixMapHandle srcPixMap = LockPixels();
  526.     PixMapHandle dstPixMap = dstShape->LockPixels();
  527.  
  528.     CGrafPtr     curPort;
  529.     GDHandle     gdh;
  530.     ::GetGWorld(&curPort, &gdh);
  531.     ::SetGWorld(fMacGWorld, NULL);
  532.     ::CopyBits((BitMap*)*srcPixMap, (BitMap*)*dstPixMap,  
  533.                 &srcRect, &dstRect, 
  534.                 srcCopy, NULL);
  535.     ::SetGWorld(curPort, gdh);    
  536.     
  537.     ::UnlockPixels(dstPixMap);
  538.     ::UnlockPixels(srcPixMap);
  539. #endif
  540.  
  541. #ifdef FW_BUILD_WIN
  542. #endif
  543. }
  544.  
  545. //------------------------------------------------------------------------------
  546. //    • FW_CBitmapShapeRep::SetBitmapParts
  547. //------------------------------------------------------------------------------
  548.  
  549. void FW_CBitmapShapeRep::SetBitmapParts(const FW_CBitmapShape& bitmapShape, const FW_SPlatformRect& bounds)
  550. {
  551.     // ATTENTION: temporary code
  552. #ifdef FW_BUILD_MAC
  553.     Rect dstRect = bounds;
  554.     if (dstRect.right > fWidth)
  555.         dstRect.right = fWidth;
  556.     if (dstRect.bottom > fHeight)
  557.         dstRect.bottom = fHeight;
  558.     
  559.     short width, height, pixelSize, rowBytes;
  560.     GetBitmapInfo(width, height, rowBytes, pixelSize);
  561.  
  562.     Rect srcRect = {0, 0, dstRect.bottom - dstRect.top, dstRect.right - dstRect.left};
  563.     if (srcRect.right > width)
  564.         srcRect.right = width;
  565.     if (srcRect.bottom > height)
  566.         srcRect.bottom = height;
  567.  
  568.     dstRect = srcRect;
  569.     ::OffsetRect(&dstRect, bounds.left, bounds.top);
  570.     
  571.     FW_CBitmapShape dstShape(this);
  572.     bitmapShape->CopyPixels(dstShape, srcRect, dstRect);
  573. #endif
  574.  
  575. #ifdef FW_BUILD_MAC
  576. #endif
  577. }
  578.  
  579. //------------------------------------------------------------------------------
  580. //    • FW_CBitmapShapeRep::Flatten
  581. //------------------------------------------------------------------------------
  582.  
  583. void FW_CBitmapShapeRep::Flatten(FW_CWritableStream& stream)
  584. {
  585.     FW_CBoundedShapeRep::Flatten(stream);
  586.     
  587. #ifdef FW_BUILD_MAC
  588.     // ATTENTION: temporary code    
  589.     stream << fHeight;
  590.     stream << fWidth;
  591.     
  592.     PixMapHandle pixMap = LockPixels();
  593.     stream << (*pixMap)->pixelSize;
  594.     
  595.     short rowBytes = (*pixMap)->rowBytes ^ 0x8000;
  596.     long bitmapSize = ((long)fHeight) * rowBytes;
  597.     stream.Write((*pixMap)->baseAddr, bitmapSize);
  598.     
  599.     ::UnlockPixels(pixMap);
  600. #endif    
  601.  
  602. #ifdef FW_BUILD_WIN
  603. #endif
  604. }
  605.  
  606. //------------------------------------------------------------------------------
  607. //    • FW_CBitmapShapeRep::Unflatten
  608. //------------------------------------------------------------------------------
  609.  
  610. void FW_CBitmapShapeRep::Unflatten(FW_CReadableStream& stream)
  611. {
  612.     FW_CBoundedShapeRep::Unflatten(stream);
  613.     
  614. #ifdef FW_BUILD_MAC
  615.     // ATTENTION: temporary code
  616.     if (fMacGWorld)
  617.         DisposeGWorld(fMacGWorld);
  618.     fMacGWorld = NULL;
  619.  
  620.     stream >> fHeight;
  621.     stream >> fWidth;
  622.     stream >> fInitialPixelSize;    
  623.     
  624.     NewGWorld(fWidth, fHeight, fInitialPixelSize);
  625.  
  626.     PixMapHandle pixMap = LockPixels();
  627.     
  628.     short rowBytes = (*pixMap)->rowBytes ^ 0x8000;
  629.     long bitmapSize = ((long)fHeight) * rowBytes;
  630.     stream.Read((*pixMap)->baseAddr, bitmapSize);
  631.     
  632.     ::UnlockPixels(pixMap);
  633. #endif    
  634.  
  635. #ifdef FW_BUILD_WIN
  636. #endif
  637. }
  638.  
  639. //------------------------------------------------------------------------------
  640. //    • FW_CBitmapShapeRep::ConvertToPict
  641. //------------------------------------------------------------------------------
  642.  
  643. void FW_CBitmapShapeRep::ConvertToPict(FW_CPictShape& pictShape)
  644. {
  645. #ifdef FW_BUILD_MAC
  646.     // ATTENTION: temporary code
  647.     CGrafPtr     curPort;
  648.     GDHandle     gdh;
  649.     ::GetGWorld(&curPort, &gdh);
  650.  
  651.     PixMapHandle pixMap = LockPixels();
  652.  
  653.     ::SetGWorld(fMacGWorld, NULL);
  654.  
  655.     Rect picRect = {0, 0, fHeight, fWidth};
  656.     PicHandle hPict = ::OpenPicture(&picRect);
  657.     ::CopyBits((BitMap*)*pixMap, (BitMap*)*pixMap,  
  658.                 &picRect, &picRect, 
  659.                 srcCopy, NULL);
  660.     ::ClosePicture();
  661.     
  662.     pictShape->SetRectangle(fRect);
  663.     pictShape->SetPlatformPict(hPict);
  664.     
  665.     SetGWorld(curPort, gdh);
  666.  
  667.     ::UnlockPixels(pixMap);
  668. #endif
  669. #ifdef FW_BUILD_WIN
  670. #endif
  671. }